package com.tt.service;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.tt.dao.HotelDaoImpl;
import com.tt.entity.Hotel;

@Service
@Transactional
public class HotelserviceImpl {
	@Resource
  private HotelDaoImpl hotelDaoImpl;
	
	//���
	public boolean  addHotel(Hotel hotel) {
		int  addHotel = hotelDaoImpl.addHotel(hotel);
		if(addHotel>0){
			return true ;
		}else{
			return false;
		} 
	}
	
	//��ѯ����
	public List<Hotel>  hotelfoundAll(){
		return this.hotelDaoImpl.hotelfoundAll();
	}
	
	//ɾ�� 
	public  void  deteleHotel(Integer id){
		this.hotelDaoImpl.deteleHotel(id);
	}
	
	//�޸�
	public  void updateHotel(Hotel hotel){

		 //�ж�ͼƬ�Ƿ�Ϊ�գ�Ϊ�յĻ��͵���ͼƬ�޸�updatephoto����
		 //����Ʒԭ����ͼƬ·�����浽����Ʒ��
			if (hotel.getImg()==null||hotel.getImg().equals("")) {
				String listimg = hotelDaoImpl.updatephoto(hotel.getId());
				hotel.setImg(listimg);
			}
			//����Ϊ��,�����޸ķ���updateHotel
			hotelDaoImpl.updateHotel(hotel);
			
	}
	 //id ����
	   public Hotel showHotel(Integer id){
		   return this.hotelDaoImpl.showHotel(id);
	   }
	   
	   public Hotel showHotelsingle(Integer id){
		   return this.hotelDaoImpl.showHotelsingle(id);
	   }
}
